home *** CD-ROM | disk | FTP | other *** search
/ Night Owl 6 / Night Owl's Shareware - PDSI-006 - Night Owl Corp (1990).iso / 015a / bkdr10.zip / BACKDOOR.ASM next >
Assembly Source File  |  1991-11-11  |  3KB  |  93 lines

  1. TITLE        BACKDOOR.COM
  2.  
  3. COMMENT        |
  4. Program        BACKDOOR version 1.0 by Duane Paulson 11/11/91.
  5.  
  6. Purpose:    Batch file enhancer. Provides a two second pause during which
  7.         a user can break out of a batch file configured as an endless
  8.         loop.
  9.  
  10. Call:        BACKDOOR
  11. Returns:    DOS Errorlevel 0 if program terminated without a keypress;
  12.         DOS Errorlevel 255 if user pressed a key.
  13.  
  14. Assemble:    MASM BACKDOOR;
  15. Link:        LINK BACKDOOR;
  16.         EXE2BIN BACKDOOR BACKDOOR.COM
  17.  
  18. Assembler:    MASM 5.1
  19. |
  20. ;-------------------------------------------------------------------------------
  21. program        SEGMENT    'CODE'
  22.         ORG    100h
  23.         ASSUME    CS:program,DS:program,ES:program,SS:program
  24.  
  25. ;-- Code -----------------------------------------------------------------------
  26. main        PROC    NEAR
  27. start:        mov    ah,9        ; display opening message
  28.         mov    dx,OFFSET open_msg
  29.         int    21h        ; call dos
  30.  
  31.         mov    ah,0        ; get system timer
  32.         int    01Ah        ; call bios
  33.  
  34.         add    dx,40        ; add 40 to low word (timer ticks 18
  35.                     ;  times/sec) for approx. 2 sec. pause
  36.         mov    low_word,dx    ; store low word
  37.  
  38. waitloop:    mov    ah,0Bh        ; check for character waiting
  39.         int    21h        ; call dos
  40.  
  41.         cmp    al,0FFh        ; character waiting?
  42.         je    key_hit        ;  then exit
  43.  
  44.         mov    ah,0        ; get system timer
  45.         int    01Ah        ; call bios
  46.  
  47.         cmp    dx,low_word    ; compare low word to low_timer
  48.         jb    waitloop    ; loop until timer catches up.
  49.  
  50.         mov    ah,9        ; overwrite opening message
  51.         mov    dx,OFFSET close_msg
  52.         int    21h        ; call dos
  53.  
  54.         mov    ax,4C00h    ; normal exit -- no key was pressed
  55.         int    21h        ; exit with 0 exit code (errorlevel)
  56. ;-------------------------------------------------------------------------------
  57.  
  58. COMMENT        |
  59. If a key is hit, the following routine comes into play. First the program
  60. swallows the keystroke without echoing it, then makes sure that the keyboard
  61. buffer is empty. (Extended keys such as F-keys, PgUp, and End place 2 bytes in
  62. keyboard buffer.) Program then exits with 255 errorlevel.
  63. |
  64.  
  65. key_hit:     mov    ah,7        ; Character input without echo
  66.         int    21h        ; call dos
  67.  
  68.         mov    ah,0Bh        ; check for another character waiting
  69.         int    21h        ; call dos
  70.  
  71.         cmp    al,0FFh        ; another character waiting?
  72.         je    key_hit        ;  then loop
  73.  
  74.         mov    ah,9        ; overwrite opening message
  75.         mov    dx,OFFSET close_msg
  76.         int    21h        ; call dos
  77.  
  78.         mov    ax,4CFFh    ; exit after key is hit
  79.         int    21h        ; exit with 255 exit code (errorlevel)
  80.  
  81. main        ENDP
  82.  
  83. ;-- Data ---------------------------------------------------------------------
  84.  
  85. program_name    DB    "BACKDOOR.COM version 1.0 by Duane Paulson 11/11/91"
  86. low_word    DW    ?            ; low word of system timer
  87. open_msg    DB    "Backdoor (1.0) is open...$"
  88. close_msg    DB    25 DUP (8,32,8),'$'     ; 25 backspaces to overwrite
  89.                         ; opening message.
  90.  
  91. program        ENDS
  92.         END    start
  93.